package com.eastfair.builder.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import com.eastfair.builder.entity.ConstructionPersonnel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 施工人员信息
 * </p>
 *
 * @author linan
 * @date 2023-05-04
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ConstructionPersonnelWorkTypeEnum", description = "工种 #{HIGH_ALTITUDE_WORK_PERMIT:高空作业证;ELECTRICIAN_CERT:电工证;OTHER:其他证;-枚举")
public enum ConstructionPersonnelWorkTypeEnum implements BaseEnum {

    /**
     * HIGH_ALTITUDE_WORK_PERMIT="高空作业证"
     */
    HIGH_ALTITUDE_WORK_PERMIT("高空作业证"),
    /**
     * ELECTRICIAN_CERT="电工证"
     */
    ELECTRICIAN_CERT("电工证"),
    /**
     * OTHER="其他证"
     */
    OTHER("其他证"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ConstructionPersonnelWorkTypeEnum match(String val, ConstructionPersonnelWorkTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }


    /**
     * 根据当前枚举的name匹配
     */
    public static ConstructionPersonnelWorkTypeEnum matchByDesc(String val) {
        return Stream.of(values()).parallel().filter(item -> item.desc.equalsIgnoreCase(val)).findAny().orElse(null);
    }

    public static ConstructionPersonnelWorkTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ConstructionPersonnelWorkTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "HIGH_ALTITUDE_WORK_PERMIT,ELECTRICIAN_CERT,OTHER", example = "HIGH_ALTITUDE_WORK_PERMIT")
    public String getCode() {
        return this.name();
    }

}
